package com.chalk.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.chalk.dao.TicketOrderItemDao;
import com.chalk.model.TicketOrderItem;
import com.chalk.service.TicketOrderItemService;
import com.chalk.util.MpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author glq
 * @since 2020-12-24
 */

@Service
public class TicketOrderItemServiceImpl extends ServiceImpl<TicketOrderItemDao, TicketOrderItem> implements TicketOrderItemService {

    @Override
    public int addTicketOrderItem(TicketOrderItem entity) {
        return baseMapper.insert(entity);
    }

    @Override
    public int updateTicketOrderItem(TicketOrderItem entity) {
        return baseMapper.updateById(entity);
    }


    @Override
    public int deleteTicketOrderItem(Integer id) {
        return baseMapper.deleteById(id);
    }

    @Autowired
    MpUtil<TicketOrderItem> mpUtil;

    @Override
    public List<TicketOrderItem> getTicketOrderItems(Integer ticketOrderId) {
        EntityWrapper<TicketOrderItem> wrapper =mpUtil.getWrapper();
        wrapper.eq("ticket_order_id",ticketOrderId);
        return selectList(wrapper);
    }
}
